﻿@{
    ViewBag.Title = "EditShops";
}

<h2>EditShops</h2>

<table>
    <tr style="position:fixed;top:1px;left:119px">
        <td>Предмет</td>
        @foreach (Shop shop in ViewBag.Shops)
        {
            <td><img src="@(shop.UrlLight ?? shop.UrlDark)" /></td>
        }
        <td></td>
    </tr>

     <tr>
        <td>Предмет</td>
        @foreach (Shop shop in ViewBag.Shops)
        {
            <td><img src="@(shop.UrlLight ?? shop.UrlDark)" /></td>
        }
        <td></td>
    </tr>

    @foreach (Item item in ViewBag.Items)
    {
        using(Ajax.BeginForm("ChangeShop", new AjaxOptions(){ OnComplete="window.title='" + item.Name + " finish'", OnFailure="alert('Error!!!!!!!!!!')"}))
        {
            @Html.Hidden("itemId", item.Id)
            <tr>            
                <td>@Html.LinkOnItem(item)</td>
                 @foreach (Shop shop in ViewBag.Shops)
                 {
                     <td style="text-align:center"><input type="text" style="width:30px" value="@(item.ItemShops.Any(s=>s.Shop == shop)?(item.ItemShops.First(s=>s.Shop == shop).Position + 1).ToString():"")" name="@shop.Name" /> </td>
                 }
                <td><input type="submit" value="Сохранить" /></td>
            </tr>
        }
    }
</table>